// components/index/moreFilter/moreFilter.js
import http from '../../../utils/http'
var cityData = require('../../../utils/city.js');

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    rentPrice: '',
    areaList:[],
    selAreaIds: {},
    isfull: false,
    shownavindex: ''
  },
  ready:function(){
    //this.getBrandList()
    this.setData({
      areaList: [
        { key: 1, value: '50㎡以下' },
        { key: 2, value: '50-100㎡' },
        { key: 3, value: '100-200㎡' },
        { key: 4, value: '200-300㎡' },
        { key: 5, value: '300-400㎡' },
        { key: 6, value: '400㎡以上' }
      ]
    });
  },

  /**
   * 组件的方法列表
   */
  methods: {
    noscroll:function(){
    },
    closePop:function(){
      this.triggerEvent('closefilter');
    },
    onBtnReset: function (e) {
      this.setData({
        selAreaIds: {},
        rentPrice: ''
      })
    },
    getRentPrice: function (e) {
      this.setData({
        rentPrice: e.detail.value
      })
    },
    handleSelectArea:function(e){
      var id = e.target.dataset.id;
      var obj = this.data.selAreaIds;
      if (obj[id]){
        obj[id]=false;
      }else{
        obj[id] = true;
      }
      this.setData({
        selAreaIds: obj
      })
    },
    onBtnOnsel:function(){
      var selAreaIds = [];
      for (var key in this.data.selAreaIds) {
        if (this.data.selAreaIds[key]) {
          selAreaIds.push(key)
        }
      } 
      this.triggerEvent('dofilter', { 
        "selAreaIds": selAreaIds.join(','),
        "rentPrice": this.data.rentPrice
      });
      console.log('aaaa:', this.data.rentPrice);
    }
  }
})
